for _ in range(0, int(input())):
input()
v = list(map(int, input().split()))
p = 0
t = 0
for x in v:
if x < 0:
w = p + x
p = max(0, p + x)
if w < 0:
t += w
else:
p += x
print(abs(t))
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve(){
int n; cin>>n;
int arr[n];
for(int i = 0; i < n; i++){
cin>>arr[i];
}
int possum = 0;
for(int i = 0; i < n; i++){
if(arr[i] > 0){
possum += arr[i];
}
else{
int mini = min(possum, abs(arr[i]));
arr[i] = arr[i] + mini;
possum = possum - mini;
}
}
cout<<possum<<endl;
return ;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int tc;
cin>>tc;
while(tc--){
solve();
}
return 0;
}
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |
Char Sum | Two Strings |
Anagrams | Prime Number |